package com.limeng.es.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;

@Configuration
public class DBHelper {

    private static String DRIVER_NAME = "com.mysql.cj.jdbc.Driver";

//    @Value("${mysql.url}")
    private static String url = "jdbc:mysql://154.8.202.121:3307/lagou_position?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai";

//    @Value("${mysql.username}")
    private static String username = "root";

//    @Value("${mysql.password}")
    private static String password = "a2b7z7s3";

    private static Connection connection;

    public static Connection getConnection(){
        try{
            Class.forName(DRIVER_NAME);
            connection = DriverManager.getConnection(url,username,password);
        }catch (Exception e){
            e.printStackTrace();
        }
        return connection;
    }
}
